package com.t235.gc.biz.service.impl;

import com.t235.gc.entity.GarbageRecyclingRecord;
import com.t235.gc.dao.GarbageRecyclingRecordDao;
import com.t235.gc.biz.service.GarbageRecyclingRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 垃圾回收记录表(GarbageRecyclingRecord)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:30
 */
@Service("garbageRecyclingRecordService")
public class GarbageRecyclingRecordServiceImpl implements GarbageRecyclingRecordService {
    @Resource
    private GarbageRecyclingRecordDao garbageRecyclingRecordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param recordid 主键
     * @return 实例对象
     */
    @Override
    public GarbageRecyclingRecord queryById(Long recordid) {
        return this.garbageRecyclingRecordDao.queryById(recordid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GarbageRecyclingRecord> queryAllByLimit(int offset, int limit) {
        return this.garbageRecyclingRecordDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param garbageRecyclingRecord 实例对象
     * @return 实例对象
     */
    @Override
    public GarbageRecyclingRecord insert(GarbageRecyclingRecord garbageRecyclingRecord) {
        this.garbageRecyclingRecordDao.insert(garbageRecyclingRecord);
        return garbageRecyclingRecord;
    }

    /**
     * 修改数据
     *
     * @param garbageRecyclingRecord 实例对象
     * @return 实例对象
     */
    @Override
    public GarbageRecyclingRecord update(GarbageRecyclingRecord garbageRecyclingRecord) {
        this.garbageRecyclingRecordDao.update(garbageRecyclingRecord);
        return this.queryById(garbageRecyclingRecord.getRecordid());
    }

    /**
     * 通过主键删除数据
     *
     * @param recordid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long recordid) {
        return this.garbageRecyclingRecordDao.deleteById(recordid) > 0;
    }
}
